package com.yanqu.road.server.logic.recharge;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.recharge.RechargeOrder;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.SecretVolumeModule;

/**
 * 密卷
 */
public class SecretVolumeRecharge extends BaseRecharge {

    public SecretVolumeRecharge(GamePlayer player, MallInfo mallInfo, ActivityInfo activityInfo) {
        super(player, mallInfo, activityInfo);
    }

    @Override
    protected boolean isRepeatedBuy(String orderNo) {
        boolean isRepeated = false;
        if(GameConfig.SECRET_VOLUME_MALL_ID == mallInfo.getMallId() && player.getModule(SecretVolumeModule.class).isBuySecretVolume()){
            isRepeated = true;
        }
        return isRepeated;
    }

    @Override
    protected void repeatedBuyLogic() {

    }

    @Override
    protected String addMall(String orderNo, RechargeOrder rechargeOrder) {
        String rewardStr = "";
        if(GameConfig.SECRET_VOLUME_MALL_ID == mallInfo.getMallId()){
            if(!player.getModule(SecretVolumeModule.class).isBuySecretVolume()){
                player.getModule(SecretVolumeModule.class).buySecretVolume();
                player.getModule(CurrencyModule.class).addCurrency(mallInfo.getReward(), eLogMoneyType.Recharge, eLogMoneyType.ReChargeGet);
                logger.info("订单: {}, 购买 密卷商品: {}", orderNo, mallInfo.getMallId());
                rewardStr = mallInfo.getReward();
            }
        }
        return rewardStr;
    }

}
